123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- <template>
- <!-- 页面头部 -->
- <HomePageHead></HomePageHead>
- <HomePageNavigation></HomePageNavigation>
-
- <!-- 面包屑导航 -->
- <div class="breadcrumb">
- <div class="inner">
- <span class="location">当前位置:</span>
- <el-breadcrumb :separator-icon="ArrowRight">
- <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
- <el-breadcrumb-item :to="{ path: `/primaryNavigation/${listid}` }" v-show="name">{{ name
- }}</el-breadcrumb-item>
- <el-breadcrumb-item>{{ newsDetail.con_title }}</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- </div>
- <!-- 资讯列表 -->
- <div class="newsDetail">
- <div class="inner">
- <div class="innerDetail">
- <div class="headImg"></div>
- <div class="innerDetail1">
- <div class="leftBottom" v-html="newsDetail.content"></div>
- </div>
- <div class="footImg"></div>
- </div>
- <div class="innerLeft">
- <ul>
- <li>
- 导航列表
- </li>
- <li v-for="(item, index) in bottomMenu" :key="index">
- <NuxtLink :to="`/speciaArticle/${item.id}`" v-if="item.id == pageId && item.id != 7"
- class="active">
- {{ item.name }}
- </NuxtLink>
- <NuxtLink :to="`/speciaArticle/${item.id}`" v-else-if="item.id != pageId && item.id != 7">
- {{item.name }}
- </NuxtLink>
- </li>
- </ul>
- </div>
- <div style="clear: both;"></div>
- </div>
- </div>
- <!-- 列表页广告一 -->
- <HomeTopTenTitle :imgurl="adList[0]" v-if="adList[0]"></HomeTopTenTitle>
- <!-- 页面底部 -->
- <HomeFoot1></HomeFoot1>
- </template>
- <script setup>
- import { onMounted } from 'vue'
- import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
- import { ArrowRight } from '@element-plus/icons-vue'
- const nuxtApp = useNuxtApp();
- const axios = nuxtApp.$axios;
- //获得跳转过来的id
- const route = useRoute();
- const articleId = route.params.id; //获得该页面的id
- const listid = route.query.listId; //获得该页面的id
- const name = route.query.listName; //获得该页面的id
- const pageId = route.params.id; //获得该页面的id
- const routeHref = route.href;
- console.log(333333)
- console.log(route.href)
- const newsDetail = ref({})
- console.log(articleId)
- const routeNewsTtitle = ref("");
- //获得广告
- const adList = ref("");
- const aa = 'page'
- const getadList = async () => {
- try {
- const response = await axios.get(`/web/getWebsiteAdvertisement?ad_tag=${aa}`);
- adList.value = response.data;
- } catch (error) {
- console.error(error);
- }
- }
- onMounted(() => {
- //获得广告
- getadList()
- })
- // 定义响应式数据
- const seoData = ref({
- title: '三农资讯网',
- description: '默认描述',
- keywords: '默认关键词',
- image: 'https://example.com/default-image.jpg'
- });
- // 在 onMounted 钩子中获取数据
- onMounted(async () => {
- try {
- const response = await axios.get(`/web/getWebsiteCategoryHead?catid=${articleId}`);
- const data = response.data.website_head; // 假设接口返回的数据在 data 字段中
- console.log(seoData.value.title)
- // 更新 seoData
- seoData.value = {
- title: data.seo_title,
- description: data.seo_description,
- keywords: data.seo_keywords,
- image: data.seo_image
- };
- console.log(seoData.value.title)
- } catch (error) {
- console.error('获取 SEO 数据失败:', error);
- // 设置默认值
- seoData.value = {
- title: '三农资讯网',
- description: '默认描述',
- keywords: '默认关键词',
- image: 'https://example.com/default-image.jpg'
- };
- }
- });
- // 监听 seoData 的变化,动态设置 SEO 字段
- watch(seoData, (newVal) => {
- if (newVal.title) { // 确保 title 有值
- useSeoMeta({
- title: newVal.title, // 使用动态值
- description: newVal.description,
- ogTitle: newVal.title,
- ogDescription: newVal.description,
- ogImage: newVal.image,
- twitterTitle: newVal.title,
- twitterDescription: newVal.description,
- twitterImage: newVal.image,
- keywords: newVal.keywords
- });
- }
- }, { immediate: true });
- //获取详情
- const getNewsInfo = async () => {
- const response = await axios.get(`/web/getWebsiteFooterCategoryInfo?fcat_id=${articleId}`);
- newsDetail.value = response.data;
- console.log(newsDetail.value.title)
- if (newsDetail.value.title.length > 30) {
- routeNewsTtitle.value = newsDetail.value.title.substr(0, 30) + "...";
- }
- }
- //获得底部导航
- const bottomMenu = ref([]);
- const getBottomMenu = async () => {
- const response = await axios.get(`/web/getWebsiteFooterCategory`);
- bottomMenu.value = response.data;
- }
- onMounted(() => {
- //获得详情
- getNewsInfo()
- // 获得左侧导航
- getBottomMenu()
- })
- </script>
- <style lang="less" scoped>
- //导航条
- .breadcrumb {
- width: 1200px;
- margin: 0 auto;
- height: 22px;
- padding-bottom: 40px;
- margin-top: 40px;
- margin-bottom: 60px;
- border-bottom: 1px solid #d9d9d9;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #666666;
- line-height: 23px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- .el-breadcrumb::v-deep {
- display: inline-block;
- vertical-align: -4px;
- }
- /deep/.el-breadcrumb__inner a,
- /deep/.el-breadcrumb__inner.is-link {
- color: #666666;
- font-weight: 400;
- text-decoration: none;
- transition: var(--el-transition-color);
- }
- span {
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #666666;
- line-height: 23px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- span:hover {
- color: #666666;
- }
- .location {
- margin-right: 20px;
- width: 100px;
- height: 22px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #666666;
- line-height: 23px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- }
- // 资讯列表
- .newsDetail {
- width: 100%;
- // height: 1400px;
- // margin-bottom: 70px;
- .inner {
- width: 1200px;
- font-size: 16px;
- position: relative;
- .innerDetail {
- width: 1080px;
- margin: 0 auto;
- margin-bottom: 60px;
- .headImg {
- width: 1086px;
- height: 10px;
- background: url("../../public/special/head11.png") no-repeat 100% 100%;
- }
- .footImg {
- width: 1086px;
- height: 7px;
- background: url("../../public/special/foot01.png") no-repeat 100% 100%;
- }
- .innerDetail1 {
- width: 1086px;
- margin: 0 auto;
- padding: 30px 50px 40px;
- box-sizing: border-box;
- border-left: 1px solid #DBBE9E;
- background: url("../../public/special/mid01.png") repeat-y 100% 100%;
- }
- .leftBottom::v-deep {
- font-size: 16px;
- line-height: 40px;
- }
- }
- .innerLeft {
- width: 279px;
- position: absolute;
- top: 3px;
- left: -155px;
- .rightMenuTitle {
- width: 279px;
- height: 69px;
- font-size: 22px;
- font-weight: bold;
- line-height: 58px;
- text-align: center;
- color: #fff;
- background: url("../../public/special/projectMoreTitle.png") no-repeat;
- margin-bottom: 30px;
- }
- ul {
- li {
- a {
- display: inline-block;
- width: 144px;
- height: 60px;
- line-height: 60px;
- text-align: center;
- background-color: #F4F4F4;
- border-top: 1px #fff solid;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 16px;
- color: #000000;
- }
- }
- li:nth-child(1) {
- width: 144px;
- height: 60px;
- line-height: 60px;
- text-align: center;
- background-color: #F4F4F4;
- border-top: 1px #fff solid;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 16px;
- color: #a01c0e;
- }
- }
- .active {
- // border-left: 0;
- // border: 1px solid #028E21;
- background: #a01c0e;
- color: #fff;
- }
- }
- }
- }
- </style>
|